home *** CD-ROM | disk | FTP | other *** search
/ Aminet 45 / Aminet 45 (2001)(GTI - Schatztruhe)[!][Oct 2001].iso / Aminet / game / role / ldmud-3.2-bin.lha / mud / doc / efun / present < prev    next >
Text File  |  2001-07-09  |  2KB  |  42 lines

  1. SYNOPSIS
  2.         object present(mixed str)
  3.         object present(mixed str, object ob)
  4.  
  5. DESCRIPTION
  6.         If an object that identifies (*) to the name ``str'' is present
  7.         in the inventory or environment of this_object(), then return
  8.         it. If "str" has the form "<id> <n>" the <n>-th object matching
  9.         <id> will be returned.
  10.  
  11.         "str" can also be an object, in which case the test is much faster
  12.         and easier.
  13.  
  14.         A second optional argument ob is the enviroment where the search
  15.         for str takes place. Normally this_player() is a good choice.
  16.         Only the inventory of ob is searched, not its environment.
  17.  
  18.         (*) id (str) { return str == <name>; }
  19.         i.e. the parser applies id(str) to all objects in the vicinity
  20.         until the matching one (if any) is found.
  21.  
  22.         If you want an object to support the "<id> <n>" syntax in
  23.         conjunction with self-defined verbs (like "open chest 3") you
  24.         can do it like that:
  25.  
  26.         init () { add_action ("open_chest", "open"); }
  27.  
  28.         open_chest (str) {
  29.           if (present (str) != this_object ())
  30.               return 0; /* Not this chest */
  31.           ...
  32.         }
  33.  
  34.         Btw: if the n-th object matching "str" is searched in this_object()
  35.         and it's environment and the object is found in the environment
  36.         then it will be the n-th occurence of ``str'' in the environment
  37.         and not in both objects.
  38.  
  39. SEE ALSO
  40.         move_object(E), environment(E), this_object(E), present_clone(E)
  41.         id(A), init(A)
  42.